home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: Auge 4000 / Auge 4000 #54 (1991-04-07)(Amiga User Gruppe Einzugsgebiet 4000).zip / Auge 4000 #54 (1991-04-07)(Amiga User Gruppe Einzugsgebiet 4000).adf / RunBack / runback.a < prev    next >
Text File  |  1991-04-07  |  3KB  |  159 lines

  1. ; RUNBACK, a very small pure version that uses the NULL: device, translated
  2. ; from a C version which compiled to 848 bytes into assembly.  New size is 468
  3. ; bytes, small enough to fit in one floppy disk block.  Written 12/16/90 and
  4. ; 12/17/90 by Paul Kienitz, public domain.  Has a -delay option, like
  5. ;   RUNBACK -3 COMMAND
  6. ; makes it wait three seconds after starting the command.  The number after
  7. ; the dash must be ONE DIGIT ONLY, and it must come before the command.
  8.  
  9.  
  10.         include        "exec/types.i"
  11.         include        "exec/execbase.i"        ; for ONE symbol!
  12.         include        "libraries/dosextens.i"
  13.         include        "libraries/dos_lib.i"
  14.  
  15.  
  16. aptr        equr        a5
  17. kask        equr        a4
  18. me        equr        a3
  19. dosbase        equr        a2
  20. alen        equr        d7
  21. kiss        equr        d6
  22. koss        equr        d5
  23. lay        equr        d4
  24.  
  25.  
  26. callib:        macro
  27.           jsr        _LVO\1(a6)
  28.         endm
  29.  
  30. dcall:        macro
  31.           move.l    dosbase,a6
  32.           callib    \1
  33.         endm
  34.  
  35. _LVOFindTask        equ        -294
  36. _LVOOldOpenLibrary    equ        -408
  37. _LVOCloseLibrary    equ        -414
  38.  
  39.  
  40. ; for debugging:
  41.         xdef        BEGIN,start,exit,Spew,lenokay,nullokay,xok
  42.  
  43.  
  44. BEGIN:        bra        start
  45.  
  46. dosname:    dc.b        "dos.library",0
  47. nullname:    dc.b        "NULL:",0
  48. longerr:    dc.b        "RunBack command argument line too long!",10,0
  49. nullerr:    dc.b        "NULL: not mounted for RunBack!",10,0
  50. xerr:        dc.b        "Could not run command!  No memory?",10,0
  51.  
  52. BUFIZE        equ        300
  53. cmdstart    equ        -BUFIZE-4
  54.  
  55. start:        lea        cmdstart(sp),sp
  56.         move.l        d0,alen
  57.         move.l        a0,aptr
  58.         move.l        4,a6
  59. ;;;        sub.l        a1,a1
  60. ;;;        callib        FindTask
  61. ;;;        move.l        d0,me
  62.          move.l        ThisTask(a6),me
  63.         lea        dosname,a1
  64.         callib        OldOpenLibrary
  65.         move.l        d0,dosbase
  66.         move.l        pr_CIS(me),kiss
  67.         move.l        pr_COS(me),koss
  68.         move.l        pr_ConsoleTask(me),kask
  69.  
  70.         cmp.l        #251,alen
  71.         ble        lenokay
  72.           lea        longerr,a0
  73. ;;;          bsr        Spew
  74. ;;;          moveq        #20,d3
  75. ;;;          bra        exit
  76.            bra        spewDie
  77.  
  78. lenokay:    move.l        pr_WindowPtr(me),-(sp)
  79.         move.l        #-1,pr_WindowPtr(me)
  80.         lea        nullname,a0
  81.         move.l        a0,d1
  82.         move.l        #MODE_NEWFILE,d2
  83.         dcall        Open
  84.         move.l        (sp)+,pr_WindowPtr(me)
  85.         move.l        d0,pr_COS(me)
  86.         bne        nullokay
  87.           lea        nullerr,a0
  88. spewDie:      bsr        Spew
  89.           moveq        #20,d3
  90.           bra        exit
  91. nullokay:    move.l        d0,pr_CIS(me)
  92.         asl.l        #2,d0
  93.         move.l        d0,a0
  94.         move.l        fh_Type(a0),pr_ConsoleTask(me)
  95.  
  96.         moveq        #0,lay
  97.         cmp.b        #'-',(aptr)
  98.         bne        makecmd
  99.           move.b    1(aptr),d0
  100.           sub.b        #'0',d0
  101.           bmi        makecmd
  102.             cmp.b    #9,d0
  103.             bgt        makecmd
  104.               move.b    d0,lay            ; aha, a -delay option
  105.               mulu    #TICKS_PER_SECOND,lay
  106.               addq    #3,aptr
  107.               subq    #3,alen
  108. makecmd:    move.l        #'Run ',cmdstart(sp)
  109.         lea        cmdstart+4(sp),a0
  110. cpy:          move.b    (aptr)+,(a0)+
  111.           dbra        alen,cpy
  112.         clr.b        -(a0)        ; loop always moves one too many
  113.  
  114.         lea        cmdstart(sp),a0
  115.         move.l        a0,d1
  116.         moveq        #0,d2
  117.         move.l        pr_COS(me),d3
  118.         callib        Execute        ; TA DA
  119.         moveq        #0,d3
  120.         tst.l        d0
  121.         bne        xok
  122.           lea        xerr,a0
  123.           bsr        Spew
  124.           moveq        #10,d3
  125.  
  126. xok:        move.l        pr_COS(me),d1
  127.         callib        Close
  128.         move.l        kiss,pr_CIS(me)
  129.         move.l        koss,pr_COS(me)
  130.         move.l        kask,pr_ConsoleTask(me)
  131.         moveq        #0,d3
  132.         tst.l        lay
  133.         beq        exit
  134.           move.l    lay,d1
  135.           callib    Delay
  136.  
  137. exit:        move.l        dosbase,a1
  138.         move.l        4,a6
  139.         callib        CloseLibrary
  140.         lea        -cmdstart(sp),sp
  141.         move.l        d3,d0
  142.         rts
  143.  
  144.  
  145.  
  146. ; Spew: writes string passed in a0 to standard output.
  147.  
  148. Spew:        move.l        koss,d1
  149.         beq        nospew
  150.         move.l        a0,a1
  151. len:          tst.b        (a1)+
  152.           bne        len
  153.         sub.l        a0,a1
  154.         subq.l        #1,a1
  155.         move.l        a1,d3
  156.         move.l        a0,d2
  157.         dcall        Write
  158. nospew:        rts
  159.